 var winOnload=function(){
yb.ui.ulTab(".nav li");
yb.ui.ulTab(".immi_nav li",".immi_tab_list");
yb.ui.togClass(".applaction h6")//下拉
};

var mid=null;
var divLen=$(".gallery-thumbs .swiper-slide").length;
mid=divLen%2==0?divLen/2-1:Math.floor(divLen/2);

function scaleImg(obj){
	scaleImg.bCss=["-moz-","-ms-","-o-","-webkit-",""];
	scaleImg.s=1;
	var zIndex=0;
	var swAc=$(obj).find(".swiper-slide.swiper-slide-active");
	var swAcL=swAc.prevAll(".swiper-slide");
	var swAcR=swAc.nextAll(".swiper-slide");
	if(swAcL.length>=swAcR.length){
		zIndex=swAcL.length;
	}else{
		zIndex=swAcR.length;
	};
	for(i in scaleImg.bCss){
		swAc.css(scaleImg.bCss[i]+"transform","scale("+scaleImg.s+")").css("z-index",zIndex);
	};
	scale(swAcL,zIndex);
	scale(swAcR,zIndex);
};

function scale(obj,zIndex){
	var zInd=zIndex;
	obj.each(function(index, element) {
	scaleImg.s-=0.08;
	--zInd;
	for(var i in scaleImg.bCss){
		$(this).css(scaleImg.bCss[i]+"transform","scale("+scaleImg.s+")").css("z-index",zInd);
		};
	});
	scaleImg.s=1;
};

$(".swiper-button-white").on("click",function(){
	scaleImg(".gallery-thumbs");
	});
$(".gallery-thumbs").on("click",".swiper-slide",function(){
	scaleImg(".gallery-thumbs");
});

//yb.app.nextBtn();
yb={};
yb.tool={};
//获得类
yb.tool.getClass=function(id,className){
	var id=document.getElementById(id);
	var obj=id.getElementsByTagName("*");
	var oName=[];
	for(var i=0; i<obj.length;i++){
		if(obj[i].className==className){
			oName.push(obj[i]);
		};
	};
	return oName;
};
//添加事件
yb.tool.addEvent=function(obj,ev,fn){
	if(window.attachEvent){
		return obj.attachEvent(ev,function(){
			fn.call(this);
		})
	}else{
		return obj.addEventListener(ev,fn(),false);
	};
};

//添加事件
yb.tool.addEvent2=function(obj,ev,fn){
	if(window.attachEvent){
		return obj.attachEvent(ev,function(){
			fn.call(this);
		})
	}else{
		return obj.addEventListener(ev,fn,false);
	};
};
//获得样式
yb.tool.getStyle=function(obj,attr){
	if(obj.currentStyle){
		 return obj.currentSyle[attr];
	}else{
		return window.getComputedStyle(obj,false)[attr];
	};
};


yb.ui={};
//导航切换/tab切换
yb.ui.ulTab=function (obj1,obj2){
	if(!$(obj1).get(0)) return false;
	var obj=$(obj1).get(0).tagName.toLocaleLowerCase();
	switch(arguments.length){
		case 2:
		$(obj1).parent().on("click",obj,function(e){
			var index=$(this).index();
			$(this).addClass("active").siblings().removeClass("active");
			$(obj2).eq(index).addClass("active").siblings().removeClass("active");
		});
		break;
		default:
		$(obj1).parent().on("click",obj,function(e){
			$(this).addClass("active").siblings().removeClass("active");
		});
		break;
	};
};
//切换活动对象
yb.ui.togClass=function(obj){
	$(obj).on("click",function(){
		$(this).toggleClass("active");
	});
};
//数字递增
yb.ui.addCount=function(obj){
	$("body").on("click",obj,function(){
		var oldText=parseInt($("span",this).text());
		$("span",this).text(++oldText);
	});
};
//限制字数
yb.ui.limitText=function(area,maxlabel,maxNum){	
	var areaText=area.val();
	var textLen=areaText.length;
	if(textLen<maxNum){
		maxlabel.removeClass("red_text");
		maxlabel.text(maxNum-textLen);
	}else{			
		maxlabel.text(0);
		maxlabel.addClass("red_text");
		area.val(areaText.slice(0,maxNum))
	};
};
//限制字数2
yb.ui.limitText2=function(maxNum){	
	var areaText=$(this).val();
	var textLen=areaText.length;
	if(textLen<maxNum){
		//maxlabel.removeClass("red_text");
		//maxlabel.text(maxNum-textLen);
	}else{			
		//maxlabel.text(0);
		//maxlabel.addClass("red_text");
		$(this).val(areaText.slice(0,maxNum))
	};
};

//验证码
yb.ui.yzmTime=function(defaule,waitTime){
    if (waitTime == 0) {
		defaule.off("click").on("click",function(){
								yb.ui.yzmTime(defaule,waitTime);
								});  
       // defaule.attr("disabled",false);
        defaule.text("获取验证码");
        waitTime= waitTime;  
    } else {
		defaule.off("click");
        //defaule.attr("disabled",true);
        defaule.text("重新发送(" + waitTime-- + ")");
        setTimeout(function() {
            yb.ui.yzmTime(defaule,waitTime);
        },
        1000);
    }
};

//验证邮箱
yb.ui.checkEmal=function(val){
   var regext=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   return regext.test(val);
};
//验证手机号
yb.ui.checkPhone=function (phone) {
return (/^1\d{10}$/.test(phone));
};

//验证身份证
yb.ui.checkId=function (id) {
return (/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(id));
};

//下一张
yb.ui.nextFn=function (ul,li){
		var _this=this;
		$(_this).off("click");
		ul.animate({
			"left":ul.offset().left-li.width()+"px"
		},500,function(){
			var minl=Math.ceil(ul.offset().left)- Math.floor(-(ul.width()-li.width()/4*5));
			if(Math.abs(minl)<=1){
				ul.css("left",Math.floor(-(li.width()-(init.oDivW-li.width())/2))+"px");
			};
			$(_this).on("click",function(){
				yb.ui.nextFn.call(_this,ul,li);
			});
		});
};

//上一张
yb.ui.prevFn=function (ul,li){
	var _this=this;
	$(_this).off("click");
	ul.animate({
		"left":ul.offset().left+li.width()+"px"
	},500,function(){
		var minl=Math.ceil(ul.offset().left)-Math.floor(li.width()/4);
		if(Math.abs(minl)<=1){
			ul.css("left",-Math.ceil(ul.width()-li.width()/4*9)+"px");
		};
		$(_this).on("click",function(){
			yb.ui.prevFn.call(_this,ul,li);
		});
	})
};
//当前页
yb.ui.currentPage=function(obj,nav){
	obj.on("click","span,a",function(){
		var prt=$(this).closest(".persn_center_r_list");
		var liA=prt.find("li.active a").html();
		alert("当前为："+liA);
	});
};

//运动
yb.ui.moverTarget=function(obj,target,attr,fn){
	clearInterval(obj.timered);
	obj.timered=setInterval(function(){
		var currentStyle=0;
			if(attr=="opacity"){				
				currentStyle=parseFloat(yb.tool.getStyle(obj,attr))*100;
			}else{
				currentStyle=parseInt(yb.tool.getStyle(obj,attr));
			};
		var speed=(target-currentStyle)/6;
			speed=speed>0?Math.ceil(speed):Math.floor(speed);
			if(target==currentStyle){
				clearInterval(obj.timered);
				if(fn)fn();
			}else{
				if(attr=="opacity"){
					obj.style.opacity=(currentStyle+speed)/100;
					obj.style.filter="alpha(opcity="+(currentStyle+speed)+")";
				}else{
					obj.style[attr]=(currentStyle+speed)+"px";
				};				
			};
	},30);
};

yb.app={};
//回复
yb.app.reply=function(){
	var oReply=$(".all_comm_reverse");
	oReply.on("click",function(){
		$(this).toggleClass("active");
		if($(this).hasClass("active")){
			$(".reverse_box").hide(200);
			oReply.not($(this)).removeClass("active");
			$(this).closest(".all_comments_list_wrap").find(".reverse_box").show(200);
		}else{
			$(".reverse_box").hide(200);
		};
	});
};
//评论
yb.app.commen=function(){
	var oComment=$(".comment_btn");
	oComment.on("click",function(){
		$(this).toggleClass("active");
		if($(this).hasClass("active")){
			$(".comment_exp").hide(200);
			oComment.not($(this)).removeClass("active");
			$(this).closest(".tell_list_con").find(".comment_exp").show(200);
		}else{
			$(".comment_exp").hide(200);
		};
	});
};
//发表评论
yb.app.limitNum=function(){
	var textarea=$(".limit_text");
	textarea.each(function(){
		var maxCount=$(this).prev(".tell_h").find("i");
		var maxNum=parseInt(maxCount.text());
		$(this).keyup(function(ev){
			//var whichKey=ev.which;
			//if(!(whichKey===13||whichKey===32||(48<whichKey&&whichKey<58)))return false;
		 	yb.ui.limitText($(this),maxCount,maxNum);
		});
	});
};
yb.app.goodOrErr=function(){
	var obj=$(".new_suppor_hand");
	obj.on("click",function(){
		var textNum=parseInt($(this).text());
		$(this).toggleClass("active");
		$(this).text($(this).hasClass("active")?++textNum:--textNum);
	});
	
};
yb.app.getYzm=function(){
	var wait=10;
	$(".get_yzm_btn").on("click",function(){
		yb.ui.yzmTime($(".get_yzm_btn"),wait);
	});
	
};
//注册表单验证
yb.app.registForm=function(){
	var formJsom={};
	$(".regist_btn a").click(function(){
		var userName=$(".user_name").val();
		var sex=$(".select_sex input[checked='checked']").next("span").text();
		var email=$(".email_address").val();
		var webNum=$(".web_num").val();
		var yzm=$(".yzm").val();
		var passWord=$(".set_password").val();
		var surePsd=$(".sure_password").val();
		//console.log(yb.ui.checkEmal(email));
		
		if(userName!="" && sex!="" && email!="" && email!="" && webNum!="" && yzm!="" && passWord!="" && surePsd!=""){
			if(!(yb.ui.checkEmal(email))){
				alert("邮箱地址不正确！");
				return ;
			};
			if(passWord != surePsd){
				alert("两次密码输入不一致！");
				return ;
			}
			formJsom.userName=userName;
			formJsom.sex=sex;
			formJsom.email=email;
			formJsom.webNum=webNum;
			formJsom.yzm=yzm;
			formJsom.passWord=passWord;
		}else{
			alert("所有内容不能为空！");
		};
	});	
};
//找回密码表单验证
yb.app.retrForm=function(){
	var retrJson={};
	var obj=$(".retr_psd_btn");
	obj.find("a").click(function(e){
		var retr_web_name=$(".retr_web_name").val();
		var retr_yzm=$(".retr_yzm").val();
		var passWord=$(".set_password").val();
		var surePsd=$(".sure_password").val();
		if(retr_web_name!="" && retr_yzm!="" && passWord!="" && surePsd!=""){
			if(passWord != surePsd){
				alert("两次密码输入不一致！");
				return ;
			};
			retrJson.retr_web_name=retr_web_name;
			retrJson.retr_yzm=retr_yzm;
			retrJson.passWord=passWord;
		}else{
			alert("所有内容不能为空！");
		};
	});	
};

//首页banner
yb.app.indexBanner=function(){
	var swiper = new Swiper('.index_banner .swiper-container', {
    //pagination: '.index_banner .swiper-pagination',
    //paginationClickable: true,
    nextButton: '.index_banner .swiper-button-next',
    prevButton: '.index_banner .swiper-button-prev',
    spaceBetween:0
	});
};

//加载更多
yb.app.loadMore=function(){
	var ojb=$(".load_more");
	var loadNum=1;
	var lis="";
	ojb.click(function(){
		for(var i=0;i<loadNum;i++){
			var li='<li class="clear">';
				li+='<div class="actvy_list_l fll">';
				li+='<img src="../images/project/tell_imgs.png" align="actvy_left_img"/>';
				li+='</div>';
				li+='<div class="actvy_list_m fll">';
				li+='<h2 class="list_r_h">"走进美国 移民美国正当时"分享沙龙</h2>';
				li+='<p class="proj_desc">新西兰是一个位于南太平洋的小国，人口约400万。它由两个主要的岛屿南岛和北岛组成。两岛景色别致，一定会...</p>';
				li+='<p class="time actvy_list_time">2016-03-23   09:00  地点：深圳</p>';
				li+='<p class="appointment_people">已有200人预约</p>';
				li+='</div>';
				li+='<div class="actvy_list_r flr">';
				li+='<div class="actvy_list_btn">';
				li+='<a href="javascript:;" class="activity_btn activity_immed_btn">立即预约</a>';
				li+='<a href="javascript:;" class="activity_btn activity_detail_btn">查看详情</a>';
				li+='</div></div></li>';
				lis+=li;
		};
		$(".activity_list ul").append(lis);
	});
};
//项目详情加载更多
yb.app.commMore=function(){
	var ojb=$(".actvy_other_more_btn");
	var loadNum=1;
	var lis="";
	ojb.click(function(){
		for(var i=0;i<loadNum;i++){
			var li='<li class="clear">';
				li+='<div class="actvy_oth_list_l fll">';
				li+='<img src="../images/project/comm_logo.png">';
				li+='</div>';
				li+='<div class="actvy_oth_list_r fll">';
				li+='<h6>匿名用户 &nbsp;&nbsp;<span class="others_ago_time">3分钟钟前</span></h6>';
				li+='<p class="actvy_oth_comm_des clear"><span class="tell_func_btn click_like oth_comm_hand"><span>30</span></span></p>';
				li+='</div></li>';
				lis+=li;
		};
		$(".actvy_oth_comm_list ul").append(lis);
	});
};

//网络红人
yb.app.hotPeo=function(obj){
	var obj=$(obj);
	if(obj.settime)clearInterval(obj.settime);
	var ul=obj.find("ul");
	var li=ul.find("li");
	var liW=li.width();
	var nextBtn=obj.find(".next_btn");
	var prevBtn=obj.find(".prev_btn");
	var liNum=4;
	var objW=obj.width();
		ul.width(liW*li.length*2);
		li.width(objW/liNum);
		ul.html(ul.html()+ul.html());
		//liW=li.width();
	
	var ulW=parseInt(ul.width())/2;
	var intervalTime=5000;//自动切换时间
	//var setTime=null;
	
	nextBtn.off("click").on("click",function(){
		nextAnimate.call(this);
	});
	
	prevBtn.off("click").on("click",function(){
		prevAnimate.call(this);
	});
	
	function nextAnimate(e){
		var ulL=parseInt(ul.css("left"));
		var _this=this;
		$(this).off("click");
		ul.animate({
			"left":ulL-liW,
		},100,"linear",function(){				
				//console.log(ul.css("left"));
				if(parseInt(ul.css("left"))<=-ulW-liW){
					ul.dequeue();
					ul.css("left",-300);
				};
				
				$(_this).on("click",function(){
					nextAnimate.call(_this);
				});
		});
	};
	
	function prevAnimate(e){
		var ulL=parseInt(ul.css("left"));
		var _this=this;
		$(this).off("click");
		ul.animate({
			"left":ulL+liW,
		},100,"linear",function(){
			if(parseInt(ul.css("left"))>=liW){
				ul.css("left",-ulW+liW);
			};
			
			$(_this).on("click",function(){
				prevAnimate.call(_this);
			});
		});
	};
	obj.settime=setInterval(nextAnimate,intervalTime);
	// console.log($(".hot_web_swiper1").settime);
		obj.hover(function(e){
			clearInterval(obj.settime);
		},function(e){
			obj.settime=setInterval(nextAnimate,intervalTime);
		});
};

yb.app.hotNavLiTab=function(e){
		var clickNum=[1];	
	$(".hot_web_nav li").click(function(){
		var toSwiper=true;
		var index=$(this).index()+1;
		for(var i in clickNum){
			if(clickNum[i]==index){
				toSwiper=false;
				};
		};
		if(toSwiper)clickNum.push(index);
		if(!toSwiper)return;
		setTimeout(function(){
			if(toSwiper){
				yb.app.hotPeo(".hot_web_swiper"+index);//网络红人切换
				};
		},120);
	});
};

yb.app.itemScale=function(e){
	var obj=$(".part_in_item");
	var lenght=obj.length;
	var objL=lenght%10;
	if(objL==0)objL=lenght-2;
	var browers=['-webkit-',"-moz-","-ms-","-o-",""];
	var oldTop=null;
	var oldLeft=null;
	var oldStyle=null;
	
	obj.each(function(i,obj){
		var scaleNum=Math.random()*objL+2;
			scaleNum=Math.ceil(scaleNum);
			//Math.abs(newTop-topNum)<170?newTop=Math.random()*430:topNum=newTop;
			//Math.abs(newLeft-leftNum)<170?newLeft=Math.random()*430:leftNum=newLeft;
		var topNum=Math.random()*430;
			topNum=Math.round(topNum);
		var leftNum=Math.random()*860;
			leftNum=Math.round(leftNum);
		for(var j=0; j<browers.length; j++){
			this.style[browers[j]+"transform"]='scale('+scaleNum/10+')';
			this.style.left=leftNum+"px";
			this.style.top=topNum+"px";
			$(this).css("z-index",scaleNum-2);
		};
	});
	
	obj.hover(function(){
		oldLeft=$(this).css("left");
		oldTop=$(this).css("top");
		oldStyle=$(this).attr("style");
		$(this).addClass("active").css({
		 	"top":oldTop+"px",
			"left":oldLeft+"px",
			"transform":"",
			"-webkit-transform":"",
			"z-index":objL+1
		});
	},function(){
		$(this).removeClass("active").removeAttr("style").attr("style",oldStyle);
	});
};

//热门资讯banner
yb.app.inverBanner=function(){
	var oDiv=$(".inverst_news_banner");
	var ul=oDiv.find("ul");
	var li=ul.find("li");
	var liLength=li.length;
	var prevBtn=oDiv.find(".inver_prev_btn");
	var nextBtn=oDiv.find(".inver_next_btn");
	var layerR=oDiv.find(".back_layer_l");
	var layerL=oDiv.find(".back_layer_r");
	
	init={
		oDivW:$(window).width()>1200?$(window).width():1200, //设置最大盒子宽度
		liH:400,//设置元素高度
		atoTime:000//自动轮播时间，0为不轮播
	};
	
	oDiv.width(init.oDivW).height(init.liH);
	li.width(Math.ceil(init.oDivW/3*2)).height(init.liH);
	prevBtn.height(init.liH).css("left",(init.oDivW-li.width())/2-40);
	nextBtn.height(init.liH).css("left",li.width()+(init.oDivW-li.width())/2+10);
	ul.width(li.width()*(liLength+2));
	ul.css("left",Math.floor(-(li.width()-(init.oDivW-li.width())/2))+"px");
	li.eq(liLength-1).clone(true).prependTo(ul);
	li.eq(1).clone(true).appendTo(ul);
	layerL.css({
		"width":(init.oDivW-li.width())/2,
		"height":init.liH,
		"left":0
	});
	layerR.css({
		"width":(init.oDivW-li.width())/2,
		"height":init.liH,
		"left":li.width()+(init.oDivW-li.width())/2
	});
	nextBtn.off("click").on("click",function(){
		yb.ui.nextFn.call(this,ul,li);
	});
	prevBtn.off("click").on("click",function(){
		yb.ui.prevFn.call(this,ul,li);
	});
	clearInterval(window.autoTimer);
	if(init.atoTime!=0){
		clearInterval(window.autoTimer);
		window.autoTimer=setInterval(function(){
			nextBtn.trigger("click");
		},init.atoTime);
		oDiv.hover(function(){
			clearInterval(window.autoTimer);
		},function(){
			window.autoTimer=setInterval(function(){
				nextBtn.trigger("click");
			},init.atoTime);
		});
	};
};

//购物车
yb.app.goodsSel=function(){
	var selAll=$(".select_all");
	var selShop=$(".select_shop");
	var oneDel=$(".del_goods");
	var delAtv=$(".del_active_btn");
	var selGoods=$(".selected_goods i");
	var onePrice=$(".one_price i");
	var totalPrice=$(".total_amount i b");
	
	function actveEle(){
		return $(".select_shop.active");
	};
	function ttlPrice(){
		var sumPrice=0;
		actveEle().each(function(){
			var thisTr=$(this).closest("tr");
			sumPrice+=Number(thisTr.find(".one_price").text())*Number(thisTr.find(".count").text());
		});		
		return sumPrice;
	};
	
	function sumCont(){
		var sumCont=null;
		actveEle().each(function(){
			var thisTr=$(this).closest("tr");
			sumCont+=Number(thisTr.find(".count").text());
		});
		return sumCont;
	};
	
	selAll.click(function(){
		selAll.toggleClass("active");
		if(selAll.hasClass("active")){
			selShop.addClass("active");
			selGoods.text(sumCont());
			totalPrice.text(ttlPrice());
		}else{
			selShop.removeClass("active");
			selGoods.text(0);
			totalPrice.text(0);
		};
	});
	
	selShop.click(function(){
		$(this).toggleClass("active");
		if(actveEle().length==selShop.length){
			selAll.addClass("active");
			selGoods.text(sumCont());
			totalPrice.text(ttlPrice());
		}else{
			selAll.removeClass("active");
			selGoods.text(sumCont());
			totalPrice.text(ttlPrice());
		};
	});
	
	oneDel.click(function(){
		if($(this).closest("tr").find(".select_shop").hasClass("active")){
			var cfm=confirm("确定删除？");
			if(cfm){
				$(this).closest("tr").remove();
				selGoods.text(sumCont());
				totalPrice.text(ttlPrice());
			};
		};
	});
	
	delAtv.click(function(){
		var actTr=$(".select_shop").filter(".active").closest("tr");
		if(actTr.length!=0){
			var cmf=confirm("确定删除选中项？");
			if(cmf){
				actTr.remove();
				selGoods.text(sumCont());
				totalPrice.text(ttlPrice());
			};
		}else{
			alert("请选择！")
		};
	});
};

yb.app.getLocation=function(){
	var myprovince = remote_ip_info['province'];
	var mycity = remote_ip_info['city'];
	//var mydistrict = remote_ip_info['district'];
	new PCAS('location_p', 'location_c', 'location_a', myprovince+"省", mycity+"市", '');
};

//账号设置
yb.app.addres=function(){
	var showLy=$(".estbsh_adres .basic_info_btn");
	var saveBtn=$(".save_btn");
	var inserBefore=$(".estbsh_adres");
	var lybox=$(".add_rec_ads");
	var closeThis=$(".close_this");
	var adsJson={};
	
	showLy.click(function(){
		lybox.addClass("active");
		lybox.find("input").val("");
		saveBtn.off("click").on("click",newAdrs);
	});
	
	closeThis.click(function(){
		lybox.removeClass("active");
	});	
	
	function newAdrs(){
		var recPeo=$.trim($(".rec_peo input").val());
		var locationP=$.trim($("#location_p").val());
		var locationC=$.trim($("#location_c").val());
		var locationA=$.trim($("#location_a").val());
		var adsDetail=$.trim($(".ads_detail input").val());
		var phoneNum=$.trim($(".phone_num input").val());
		var tellNum=$.trim($(".tell_num input").val());
		var emailAds=$.trim($(".email_ads input").val());
		//console.log(yb.ui.checkEmal(emailAds));
		if(recPeo!=" " && locationP!=" " && locationC!=" " && locationA!="" && adsDetail!="" && (phoneNum!="" || tellNum!="") && emailAds!=""){
			if(phoneNum != ""){
				if(!yb.ui.checkPhone(phoneNum)){
					alert("手机号不正确！");
					return;
				};
			};
			if(!yb.ui.checkEmal(emailAds)){
					alert("邮箱地址不正确 ！");
					return;
			}else{
					adsJson.recPeo=recPeo;
					adsJson.adsDetail=locationP+locationC+locationA+adsDetail;
					adsJson.phoneNum=phoneNum!=""?phoneNum:tellNum;
					//adsJson.tellNum=tellNum;
					adsJson.emailAds=emailAds;
					console.log(adsJson);
					var resAds='<div class="receipt_adres_detail">';
						resAds+='<h3 class="receipter_name">'+adsJson.recPeo+'</h3>';
						resAds+='<div class="receipter_item receipter_item_1">';
						resAds+='<span class="fll">收货人：</span>';
						resAds+='<div class="receipter_text_con fll">'+adsJson.recPeo+'</div>';
						resAds+='</div>';
						resAds+='<div class="receipter_item receipter_item_2">';
						resAds+='<span class="fll">所在地区：</span>';
						resAds+='<div class="receipter_text_con fll">'+adsJson.adsDetail+'</div>';
						resAds+='</div>';
						resAds+='<div class="receipter_item">';
						resAds+='<span class="fll">手机号码：</span>';
						resAds+='<div class="receipter_text_con  fll">'+adsJson.phoneNum+'</div>';
						resAds+='</div>';
						resAds+='<div class="receipter_item clear">';
						resAds+='<span class="fll">电子邮箱：</span>';
						resAds+='<div class="receipter_text_con fll">'+adsJson.emailAds+'</div>';
						resAds+='</div>';
						resAds+='<div class="respt_btn_div">';
						resAds+='<a href="javascript:;" class="bdge respt_btn del_respt">删除</a>';
						resAds+='<a href="javascript:;" class="bdge respt_btn edit_respt">编辑</a>';
						resAds+='<a href="javascript:;" class="bdge respt_btn">设为默认</a></div>';
						resAds+='</div>';
						inserBefore.before(resAds);
						lybox.removeClass("active");
						saveBtn.off("click");
				};
			
		}else{
			alert("信息不能留空！");
		};		
	};
	
	$("body").on("click",".respt_btn",function(e){
		var closest=$(this).closest(".receipt_adres_detail");
		if($(e.currentTarget).hasClass("edit_respt")){
			var name=closest.find(".receipter_item_1 .receipter_text_con").text();
			var address=closest.find(".receipter_item_2 .receipter_text_con").text();
			var phone=closest.find(".tell_phone").text();
			var email=closest.find(".email_adrs").text();
			
			$(".rec_peo input").val(name);
			$(".ads_detail input").val(address);
			phone.length==11?$(".phone_num input").val(phone):$(".tell_num input").val(phone);			
			$(".email_ads input").val(email);
			lybox.addClass("active");
			saveBtn.off("click").on("click",function(){editAdrs(closest)});
			
		}else if($(e.currentTarget).hasClass("del_respt")){
			closest.remove();
		};
	});
	
	function editAdrs(closest){
		var recPeo=$.trim($(".rec_peo input").val());
		var locationP=$.trim($("#location_p").val());
		var locationC=$.trim($("#location_c").val());
		var locationA=$.trim($("#location_a").val());
		var adsDetail=$.trim($(".ads_detail input").val());
		var phoneNum=$.trim($(".phone_num input").val());
		var tellNum=$.trim($(".tell_num input").val());
		var emailAds=$.trim($(".email_ads input").val());
		console.log(yb.ui.checkEmal(emailAds));
		if(recPeo!=" " && locationP!=" " && locationC!=" " && locationA!="" && adsDetail!="" && (phoneNum!="" || tellNum!="") && emailAds!=""){
			if(phoneNum != ""){
				if(!yb.ui.checkPhone(phoneNum)){
					alert("手机号不正确！");
					return;
				};
			};
			if(!yb.ui.checkEmal(emailAds)){
					alert("邮箱地址不正确 ！");
					return;
			}else{
					adsJson.recPeo=recPeo;			
					adsJson.adsDetail=adsDetail;
					adsJson.phoneNum=phoneNum!=""?phoneNum:tellNum;
					//adsJson.tellNum=tellNum;
					adsJson.emailAds=emailAds;
					
					closest.find(".receipter_name").text(adsJson.recPeo);
					closest.find(".receipter_item_1 .receipter_text_con").text(adsJson.recPeo);
					closest.find(".receipter_item_2 .receipter_text_con").text(adsJson.adsDetail);
					closest.find(".tell_phone").text(adsJson.phoneNum);
					closest.find(".email_adrs").text(adsJson.emailAds);
					lybox.removeClass("active");
					saveBtn.off("click");
				};
			
		}else{
			alert("信息不能留空！");
		};
	};
};

yb.app.pages=function(){
	var pagesDiv=$(".buyed_prjct_page");
	var navLi=$(".already_buy_nav");
	yb.ui.currentPage(pagesDiv,navLi);
};

//我的项目切换页
yb.app.myPrjctPages=function(){
	var pagesDiv=$(".my_prjct_pages");
	var navLi=$(".my_project_nav");
	yb.ui.currentPage(pagesDiv,navLi);
	
};

//显示更多地址
yb.app.showMoreAdrs=function(){
	var obj=$(".show_more_adrs_btn");
	var rcptAdrs=$(".rcpt_adrs ul");
	obj.click(function(){
		$(this).toggleClass("active");
		$(this).hasClass("active")?rcptAdrs.addClass("active"):rcptAdrs.removeClass("active");
	});
};
//确认申请
yb.app.sureApp=function(){
	var btn=$(".sure_app_btn");
	var aggremBtn=$(".read_aggremt b");
	var appJson={};
	btn.click(function(e){
		if(!aggremBtn.hasClass("active")){
			alert("您未同意协议");
			return false;
		};
		var your_name=$.trim($(".your_name").val());
		var sex=$.trim($(".sex").prev("input:checked").next().text());
		var your_id=$.trim($(".your_id").val());
		var your_area=$.trim($(".your_area").val());
		var your_xl=$.trim($(".your_xl").val());
		var your_ll=$.trim($(".your_ll").val());
		var your_phone=$.trim($(".your_phone").val());
		var your_email=$.trim($(".your_email").val());
		
		if(your_name!="" && your_id!="" && your_area!="" && your_xl!="" && your_ll!="" && your_phone!=""){
			if(!yb.ui.checkId(your_id)){
				alert("身份证号有误！")
				return false;
			};
			if(!yb.ui.checkPhone(your_phone)){
				alert("手机号不正确！")
				return false;
			};
			appJson.your_name=your_name;
			appJson.sex=sex;
			appJson.your_id=your_id;
			appJson.your_area=your_area;
			appJson.your_xl=your_xl;
			appJson.your_ll=your_ll;
			appJson.your_phone=your_phone;
			appJson.your_email=your_email;
			alert(JSON.stringify(appJson));
		}else{
			e.preventDefault();
			alert("内容填写不全！");
		};
	});
	
};
//同意申请
yb.app.agreeApp=function(){
	var btn=$(".agree_agg_btn");
	var aggremBtn=$(".read_aggremt b");
	btn.click(function(){
		if(!aggremBtn.hasClass("active")){
			alert("您未同意协议");
			return false;
		};
	});
};

//发布项目限制字数
yb.app.minText=function(){
	var obj=$(".min_text");
	obj.keyup(function(){
		yb.ui.limitText2.call(this,15);
	});
	
};

//发布项目限制金额
yb.app.minTotal=function(){
	var oInput=$(".min_total");
	oInput.blur(function(){
		var theVal=$(this).val();
		if(theVal=="")return;
		if(!isNaN(theVal)){
			if(theVal<8)alert("最小为8")
		}else{
			alert("请填写金额");
		};
	});
};

//发布项目限制天数
yb.app.minDay=function(){
	var oInput=$(".min_day");
	oInput.blur(function(){
		var theVal=$(this).val();
		if(theVal=="")return;
		if(!isNaN(theVal)){
			if(theVal<8)alert("最小为8")
		}else{
			alert("请填写数字")
		};
	});
};
//我代理的客户，对话客服
yb.app.chat=function(){
	var closeBtn=$(".close_chat");
	var statusBtn=$(".client_status");
	var chatBox=$(".chat_win_box");
	statusBtn.click(function(){
		chatBox.addClass("active");
	});
	closeBtn.click(function(){
		chatBox.removeClass("active");
	});
};

//选择日期
yb.app.selDate=function(){
	$("#datetimepicker1,#datetimepicker2").on("click",function(e){
		e.stopPropagation();
		$(this).lqdatetimepicker({
			css : 'datetime-day',
			dateType : 'D',
			selectback : function(){

			}
		});
	});
};

//最高人气红人 
yb.app.most=function(){
	yb.app.hotPeo(".most_popular_list");
};

//资讯列表banner
yb.app.infoBanner=function(){
	var lUl=document.querySelector(".img_swpier_left ul");
	var lLi=document.querySelectorAll(".img_swpier_left li");
	var lliH=lLi[0].offsetHeight;
	var autoTime=3000;
	var timer=null;
	
	var rUl=document.querySelector(".img_swpier_right ul");
	var rLi=document.querySelectorAll(".img_swpier_right li");
	var rliH=rLi[0].offsetHeight;
	var rImgs=document.querySelectorAll(".img_swpier_right li .back_layer");
	var rImgsL=rImgs.length;
	
	var lLayers=$(".where_buy_hose");
	
	var nowCurent=null;
	
	for(var i=0; i<rImgsL;i++){
		rImgs[i].index=i;
		//rImgs[i].createEvent("click");
		yb.tool.addEvent2(rImgs[i],"click",function(){
				smallImgOpacity.call(this);
		});
	};
	rImgs[1].click();
	//rImgs[1].dispatchEvent("click");
	function smallImgOpacity(){
		if(nowCurent==this.index) return;
		nowCurent=this.index;
		var bLs=this.parentNode.parentNode;
		var liH=bLs.querySelector("li").offsetHeight;
			var theLayer=bLs.querySelectorAll(".back_layer");
			for(var i=0; i<theLayer.length;i++){
				yb.ui.moverTarget(theLayer[i],100,"opacity");
				theLayer[i].parentNode.style.border="";
			};			
			yb.ui.moverTarget(this,0,"opacity");
			this.parentNode.style.border="1px solid #ffff00";			
			var theIndex=this.index;
			
			if(theIndex==0||theIndex==1){
				yb.ui.moverTarget(bLs,0,"top");
				leftMove.call(this);
			}else
			if(theIndex==theLayer.length-2||theIndex==theLayer.length-1){
				yb.ui.moverTarget(bLs,-(theLayer.length-3)*liH,"top");
				leftMove.call(this);
			}else{
				var ulTop=this.parentNode.parentNode.offsetTop;
				yb.ui.moverTarget(bLs,-(this.index-1)*liH,"top");
				leftMove.call(this);
			};
		lLayers.removeClass("active").eq(this.index).addClass("active");
	};
	function leftMove(){
		for(var i=0; i<lLi.length; i++){
			lLi[i].style.zIndex=1;
		};
		lLi[this.index].style.zIndex=2;
		lLi[this.index].style.height=0;
		yb.ui.moverTarget(lLi[this.index],lliH,"height");
	};
	
	if(autoTime!=0&&(typeof autoTime)=="number"){
		var tarI=2;
		clearInterval(timer);
		yb.tool.addEvent2(rUl,"mouseover",function(){
			clearInterval(timer);
		});
		yb.tool.addEvent2(rUl,"mouseleave",autoMove);
		
		function autoMove(){			
			timer=setInterval(function(){
				var inI=tarI%rImgsL;
				rImgs[inI].click();
				tarI++;
			},autoTime);
		}
		autoMove();
	};
	
};

//咨询列表加载更多
yb.app.infoLoadMore=function(){
	var btn=$(".info_load_more");
	btn.click(function(){
		var li='<div class="info_b_left_list clear">';
			li+='<div class="info_b_l_img fll">';
			li+='<img src="../images/webcast/banner_1.png" alt="">';
			li+='<span class="label_bdge label_bdge_green">热门</span>';
			li+='</div>';
			li+='<div class="info_b_l_text fll">';
			li+='<h1 class="info_list_h">中国移民心目中的新西兰，犹如世外桃源</h1>';
			li+='<p class="info_list_des ellipsis_2">新西兰是一个位于南太平洋的小国，人口约400万。它由两个主要的岛屿和岛组成，两岛景色别致，一定会两岛景色别致，一定会两岛景色别致，一定会</p>';
			li+='<p class="info_list_time"><span class="public_time">时间：2016-14-30</span><span class="browse_count">浏览量：500</span></p>';
			li+='</div>';
			li+='</div>';
		$(this).before(li);
	});
};

//签证详情右侧边图片滚动
yb.app.rightAside=function(){
	var obj=$(".visa_d_r_list_box");
	var upBtn=$(".up_btn");
	var downBtn=$(".down_btn");
	var dl=$(".visa_d_r_list_box dl");
	var dlH=dl.outerHeight(true);
	var dls=$(".visa_right_aside dl").clone(true);
	var asideDiv=$(".visa_right_aside");
		asideDiv.append(dls);
	var moveObj=document.querySelector(".visa_right_aside");
	upBtn.click(function(){
		upfn.call(this);
	});
	
	function upfn(){
		var _this=this;
		$(_this).off("click");
		var curTop=parseInt(asideDiv.css("top"));
		if(dl.length*dlH==-curTop){
			asideDiv.css("top",0);
			curTop=parseInt(asideDiv.css("top"));
		};
		yb.ui.moverTarget(moveObj,curTop-dlH,"top",function(){
			$(_this).click(function(){
				upfn.call(this);
			});
		});
	};
	
	downBtn.click(function(){
		downfn.call(this);
	});
	
	function downfn(){
		var _this=this;
		$(_this).off("click");
		var curTop=parseInt(asideDiv.css("top"));
		if(curTop==0){
			asideDiv.css("top",-dl.length*dlH+"px");
			curTop=parseInt(asideDiv.css("top"));
		};
		yb.ui.moverTarget(moveObj,curTop+dlH,"top",function(){
			$(_this).click(function(){
				downfn.call(this);
			});
		});
	}
	
};

//我的消息删除订单
yb.app.delOrderNews=function(){
	var obj=$(".order_list_head");
	obj.on("click","span",function(){
		var cfm=confirm("删除此订单？")
		if(cfm)$(this).closest("li").remove();
	});
};
yb.tool.addEvent(window,"onload",winOnload,false);






















